<script lang="ts" setup>
import { ref, nextTick } from 'vue'
import wjzs from '@/components/wjzs.vue'
/*
 * 打开弹框
 */
//
const dialogVisible = ref<boolean>(false)
// 入参
const wjzsRef = ref<InstanceType<typeof wjzs>>()
const url = ref<string>('')
const title = ref<string>('')
const wjlx = ref<string>('word')
// 生命周期
const openDialog = (urlVal: string, titleVal: string, lx?: string) => {
  if (lx) wjlx.value = lx
  url.value = urlVal
  title.value = titleVal
  dialogVisible.value = true
  nextTick(() => {
    wjzsRef.value!.init()
  })
}

/**
 * 打印
 */
const hanldePrint = () => {
  //
}

/**
 * 下载
 */
const downloadFile = () => {
  window.location.href = url.value
}

defineExpose({ openDialog })
</script>
<template>
  <el-dialog v-model="dialogVisible" :title="title" width="80%" :close-on-click-modal="false">
    <div class="dialog-box">
      <!--文件-->
      <wjzs ref="wjzsRef" :wjlx="wjlx" :url="url" />
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="hanldePrint">打 印</el-button>
        <el-button type="primary" @click="downloadFile">下 载</el-button>
        <el-button @click="dialogVisible = false">关 闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<style lang="scss" scoped>
.dialog-box {
  width: 100%;
  height: 70vh;
}
</style>
